package my.study.demo.proxy.client;

import my.study.demo.proxy.jhlproxy.JHLClassLoader;
import my.study.demo.proxy.jhlproxy.JHLInvocationHandler;
import my.study.demo.proxy.jhlproxy.JHLProxy;

import java.lang.reflect.Method;

public class JMeipo implements JHLInvocationHandler {

    private Object target;

    public Object getInstance(Object target) throws Exception {
        this.target = target;
        Class<?> clazz = target.getClass();
        return JHLProxy.newProxyInstance(new JHLClassLoader(), clazz.getInterfaces(), this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        method.invoke(this.target, args);
        return null;
    }
}
